package iterator.iterator;

import iterator.Iterator;
import iterator.entity.Student;
import iterator.impl.PersonContainer;

public class StudentIterator implements Iterator {
    int curr = 0;
    PersonContainer container;

    public StudentIterator(PersonContainer container) {
        this.container = container;
    }

    @Override
    public boolean hasNext() {
        if (++curr>= container.size) {
            return false;
        }
        return container.container[curr] instanceof Student || hasNext();
    }

    @Override
    public Object next() {
        return container.container[curr];
    }
}
